<script lang="ts" setup>
import { ref } from 'vue'
import axios from 'axios'

const form = ref({
  email: '',
  checkCode: '',
})

const onSubmit = async () => {
  const res = await axios.post('http://localhost:3000/email/login', form.value)
  console.log(res)
}

const sendCode = async () => {
  const res = await axios.post('http://localhost:3000/email', { email: form.value.email })
  console.log(res)
}

</script>

<template>
  <div style="width: 300px; padding: 20px;">
    <el-form ref="ruleFormRef" style="max-width: 600px" label-width="auto" class="demo-ruleForm">
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="form.email" type="email" />
      </el-form-item>
      <el-form-item label="验证码" prop="checkCode">
        <el-input v-model="form.checkCode" />
      </el-form-item>
      <el-form-item>
        <el-button @click="onSubmit" type="primary">登录</el-button>
        <el-button @click="sendCode">发送验证码</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
